package com.java.zhuiyun.api.jielongidiomquestion.controller;

import com.java.zhuiyun.api.jielongidiomquestion.entity.JieLongIdiomQuestion;
import com.java.zhuiyun.api.jielongidiomquestion.model.JieLongIdiomQuestionModel;
import com.java.zhuiyun.api.jielongidiomquestion.service.JieLongIdiomQuestionService;
import com.java.zhuiyun.common.response.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName JieLongIdiomQuestionController
 * @Description TODO 关卡词库管理接口 后台管理查询词库、单查词语信息、保存成语信息、添加成语
 * @Author 杨友朋
 * @Date 2023/9/13 9:20
 **/
@RestController
@RequestMapping("/JieLongIdiomQuestion")
@Api(tags = "关卡词库管理")
public class JieLongIdiomQuestionController {
    @Resource
    JieLongIdiomQuestionService jieLongIdiomQuestionService;

    /**
    * @Author 杨友朋
    * @Description TODO 后台管理查询词库
    * @Date 2023/10/12 11:17
    * @Return CommonResult
    * @param levelId
    */
    @GetMapping("/selectQuestion")
    @ApiOperation(value = "后台管理查询词库")
    public CommonResult selectQuestion( Integer levelId){
        return CommonResult.ok(jieLongIdiomQuestionService.selectQuestion(levelId));
    }

    @GetMapping("/uniSelectQuestion")
    @ApiOperation(value = "uni-app查询词库")
    public CommonResult uniSelectQuestion( Integer levelId){
        return CommonResult.ok(jieLongIdiomQuestionService.selectQuestion(levelId));
    }
    /**
    * @Author 杨友朋
    * @Description TODO 单查词语信息
    * @Date 2023/10/12 11:20
    * @Return CommonResult
    * @param id
    */
    @GetMapping("/selectQuestById")
    @ApiOperation(value = "单查词语信息")
    public CommonResult selectQuestById(Integer id){
        return CommonResult.ok(jieLongIdiomQuestionService.selectQuestById(id));
    }

    /**
    * @Author 杨友朋
    * @Description TODO 保存成语信息
    * @Date 2023/10/12 11:22
    * @Return CommonResult
    * @param jieLongIdiomQuestion
    */
    @PostMapping("/saveWordInfo")
    @ApiOperation(value = "保存成语信息")
    public CommonResult saveWordInfo(@RequestBody JieLongIdiomQuestionModel jieLongIdiomQuestion){
        return jieLongIdiomQuestionService.saveWordInfo(jieLongIdiomQuestion);
    }

    /**
    * @Author 杨友朋
    * @Description TODO 添加成语
    * @Date 2023/10/12 11:22
    * @Return CommonResult
    * @param jieLongIdiomLevel
    */
    @PostMapping("/insertIdiom")
    @ApiOperation(value = "添加成语")
    public CommonResult insertIdiom(@RequestBody JieLongIdiomQuestionModel jieLongIdiomLevel){
        return jieLongIdiomQuestionService.insertIdiom(jieLongIdiomLevel);
    }

    /**
    * @Author 杨友朋
    * @Description TODO 删除成语
    * @Date 2023/10/20 13:56
    * @Return CommonResult
    * @param id
    */
    @GetMapping("/delIdiom")
    @ApiOperation(value = "删除成语")
    public CommonResult delIdiom(Integer id){
        return jieLongIdiomQuestionService.delIdiom(id);
    }
}
